package com.oriental.manage.service.specially.Impl;

import com.oriental.manage.service.specially.BatchMessageProcess;
import com.oriental.riskfront.api.enums.TransCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * Author: yutao
 * Date: 2017/4/21
 * Time: 15:26
 * Desc：
 */
@Service("")
@Slf4j
public class BatchMessageHelper {

    @Autowired
    ApplicationContext applicationContext;

    private Map<String,String> typeUrl = new HashMap<>();

    private Map<String,String> beanMap = new HashMap<>();

    /**
     * 交易码
     *  @see com.oriental.riskfront.api.enums.TransCode
     */
    @PostConstruct
    public void initCache(){

        typeUrl.put(TransCode.PR0001.getCode(),"specially/personRiskInfoBatchDetail");
        typeUrl.put(TransCode.EER001.getCode(),"specially/enterpriseMchntBaseInfoBatchDetail");
        typeUrl.put(TransCode.EDEL01.getCode(),"specially/speciallyMchntBaseInfoDeleteBatchDetail");
        typeUrl.put(TransCode.UP0002.getCode(),"specially/personRiskInfoBatchDetail");
        typeUrl.put(TransCode.UP0002_1.getCode(),"specially/personRiskInfoBatchDetail");
        typeUrl.put(TransCode.ER0001.getCode(),"specially/merchantRiskInfoBatchDetail");
        typeUrl.put(TransCode.UP0004.getCode(),"specially/merchantRiskInfoBatchDetail");
        typeUrl.put(TransCode.UP0004_1.getCode(),"specially/merchantRiskInfoBatchDetail");
        typeUrl.put(TransCode.UP0004_2.getCode(),"specially/merchantRiskInfoBatchDetail");


        beanMap.put(TransCode.PR0001.getCode(),"personRiskInfoProcessImpl");
        beanMap.put(TransCode.EER001.getCode(),"enterpriseMchntBaseInfoProcessImpl");
        beanMap.put(TransCode.EDEL01.getCode(),"speciallyMchntBaseInfoDeleteProcessImpl");

        beanMap.put(TransCode.ER0001.getCode(),"merchantRiskInfoProcessImpl");
        beanMap.put(TransCode.UP0002.getCode(),"personRiskInfoUpdateProcessImpl");
        beanMap.put(TransCode.UP0002_1.getCode(),"personRiskInfoUpdateProcessImpl");
        beanMap.put(TransCode.UP0004.getCode(),"merchantRiskInfoUpdateProcessImpl");
        beanMap.put(TransCode.UP0004_1.getCode(),"merchantRiskInfoUpdateProcessImpl");
        beanMap.put(TransCode.UP0004_2.getCode(),"merchantRiskInfoUpdateProcessImpl");

    }

   public BatchMessageProcess getBatchMessageProcess(String transCode){
       String batchMessageProcessImpl = beanMap.get(transCode);
       log.info("查询特约上报商户审核详情 transCode:{},implClass:{}",transCode,batchMessageProcessImpl);
       return applicationContext.getBean(batchMessageProcessImpl,BatchMessageProcess.class);
   }


    public String getUrl(String transCode){
        String url = typeUrl.get(transCode);
        log.info("特约商户上报审核查询详细 transCode:{},url:{}",transCode,url);
        return url;
    }






}
